package com.fz.mabatis;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

/**
 * Created by xiao zeng on 2017/6/23.
 *
 *
 * jndi工具类 com/fz/mabatis
 */
public class DbHelper {
    public SqlSession ss;
    public SqlSessionFactory sf;

    public DbHelper() {
        try {
            this.sf = new SqlSessionFactoryBuilder().build(Resources.getResourceAsStream("mybatis-conf.xml"));
            this.ss = this.sf.openSession();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public SqlSession getSession() {
        return this.ss;
    }
}
